package com.tools.test.guava.controller;

import com.tools.cache.guava.annotation.LocalLock;
import com.tools.test.guava.entity.UserEntity;
import com.tools.test.guava.service.IndexService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author com.zaimi
 * @version 1.0
 * @Description: IndexController
 * <com.tools.test.guava.controller>
 * @date Created in 2020/12/7 15:43
 **/
@RestController
public class IndexController {

    @Resource
    private IndexService indexService;
    @ResponseBody
    @PostMapping(value = "/localLock")
    //@LocalLock(key = "localLock:test:arg[0]")
    public String localLock(String token) {
        UserEntity user = new UserEntity();
        user.setAge(0);
        user.setId(0L);
        user.setName("ggg");
        user.setNickName("ggg");
        indexService.save(user);
        return "sucess=====" + token;
    }
}
